"Some college",
"College graduate",
"Post graduate"),
labels = c("Less than high school",
"High school graduate",
"Some college",
"College graduate",
"Post graduate"),
ordered = TRUE)
table(survey$educ)
# household income (income)
table(survey$F9)
survey$income <- dplyr::recode(survey$F9,
`1` = "Under $7500",
`2` = "$7,501 to $15,000",
`3` = "$15,001 to $25,000",
`4` = "$25,001 to $35,000",
`5` = "$35,001 to $50,000",
`6` = "$50,001 and over",
`7` = "Not sure/refused")
survey$income <- factor(survey$income,
levels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"),
labels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"))
table(survey$income)
# age
table(survey$F4)
table(survey$F4)
survey$age <- dplyr::recode(survey$F4,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 49",
`7` = "50 to 64",
`8` = "65 and over",
`9` = "Refused")
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 and over",
"Refused"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 and over",
"Refused"))
table(survey$age)
# race
table(survey$F11)
survey$race <- dplyr::recode(survey$F11,
`1` = "White",
`2` = "Black",
`3` = "Oriental/Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
survey$race <- as.factor(survey$race)
table(survey$race)
## hispanic origin
table(survey$F10)
survey$hispanic <- factor(dplyr::recode(survey$F10,
`1` = "Yes, of Hispanic origin",
`2` = "No, not of Hispanic origin",
`3` = "Not sure"))
table(survey$hispanic, survey$race)
# politics (party)
table(survey$Q1B)
table(survey$Q1B)
survey$party <- dplyr::recode(survey$Q1B,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
table(survey$F8)
survey$ideology <- dplyr::recode(survey$F8,
`1` = "Conservative",
`2` = "Middle of the road",
`3` = "Liberal",
`4` = "Radical",
`5` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
colnames(survey)
summary(survey$S1)
survey$gender <- factor(dplyr::recode(survey$S1,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
# religion
table(survey$F7)
survey$religion <- dplyr::recode(survey$F7,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other (write in)",
`5` = "None",
`6` = "Not sure")
survey$religion <- factor(survey$religion)
table(survey$religion)
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1984 Presidential Election Survey, study no. 842105")
library(dplyr)
survey <- read.table("harris_s842105_voters_spss.tab", header = TRUE)
## change everything below
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 842105
# study year (year)
survey$year <- 1984
# geographic data (urban)
survey$urban <- NA
# geographic data (region)
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# increasing inequality (inequality)
table(survey$Q13_2)
survey$inequality <- dplyr::recode(as.character(survey$Q13_2),
`1` = "Feel",
`2` = "Don't Feel",
`3` = "Not Sure")
survey$inequality <- as.factor(survey$inequality)
table(survey$inequality)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
table(survey$F6_1)
survey$union.self <- dplyr::recode(survey$F6_1,
`0` = "No",
`1` = "Yes")
table(survey$union.self)
survey$union.other <- dplyr::recode(survey$F6_2,
`0` = "No",
`1` = "Yes")
table(survey$union.other)
table(survey$F6_4) # not sure
survey[survey$F6_4 == 1, c("union.self", "union.other", "F6_3")]
survey$union.self[survey$F6_4 == 1] <- "Not Sure"
survey$union.other[survey$F6_4 == 1] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- factor(survey$union.other)
# employment (employed)
survey$employed <- NA
# occupation
table(survey$F1)
survey$occupation <- dplyr::recode(survey$F1,
`1` = "Professional",
`2` = "Manager, official",
`3` = "Proprietor (small business)",
`4` = "Clerical worker",
`5` = "Sales worker",
`6` = "Skilled craftsman, foreman",
`7` = "Operative, unskilled laborer (except farm)",
`8` = "Service worker",
`9` = "Farmer, farm manager, farm laborer",
`10` = "Student",
`11` = "Housewife",
`12` = "Military service",
`13` = "Unemployed",
`14` = "Retired",
`15` = "Welfare",
`16` = "Disabled",
`17` = "Other (specify)",
`18` = "Not sure")
survey$occupation <- as.factor(survey$occupation)
table(survey$occupation)
# household size (hhsize)
table(survey$F2)
survey$hhsize <- as.factor(survey$F2)
table(survey$hhsize)
# education (educ)
table(survey$F5)
survey$educ <- dplyr::recode(as.character(survey$F5),
`1` = "Less than high school",
`2` = "Less than high school",
`3` = "Less than high school",
`4` = "Less than high school",
`5` = "High school graduate",
`6` = "Some college",
`7` = "Some college",
`8` = "College graduate",
`9` = "Postgraduate")
survey$educ <- factor(survey$educ,
levels = c("Less than high school",
"High school graduate",
"Some college",
"College graduate",
"Post graduate"),
labels = c("Less than high school",
"High school graduate",
"Some college",
"College graduate",
"Post graduate"),
ordered = TRUE)
table(survey$educ)
# household income (income)
table(survey$F9)
survey$income <- dplyr::recode(survey$F9,
`1` = "Under $7500",
`2` = "$7,501 to $15,000",
`3` = "$15,001 to $25,000",
`4` = "$25,001 to $35,000",
`5` = "$35,001 to $50,000",
`6` = "$50,001 and over",
`7` = "Not sure/refused")
survey$income <- factor(survey$income,
levels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"),
labels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"))
table(survey$income)
# age
table(survey$F4)
survey$age <- dplyr::recode(survey$F4,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 49",
`7` = "50 to 64",
`8` = "65 and over",
`9` = "Refused")
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 and over",
"Refused"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 and over",
"Refused"))
table(survey$age)
# race
table(survey$F11)
survey$race <- dplyr::recode(survey$F11,
`1` = "White",
`2` = "Black",
`3` = "Oriental/Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
survey$race <- as.factor(survey$race)
table(survey$race)
## hispanic origin
table(survey$F10)
survey$hispanic <- factor(dplyr::recode(survey$F10,
`1` = "Yes, of Hispanic origin",
`2` = "No, not of Hispanic origin",
`3` = "Not sure"))
table(survey$hispanic, survey$race)
# politics (party)
table(survey$Q1B)
survey$party <- dplyr::recode(survey$Q1B,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
# politics (ideology)
table(survey$F8)
survey$ideology <- dplyr::recode(survey$F8,
`1` = "Conservative",
`2` = "Middle of the road",
`3` = "Liberal",
`4` = "Radical",
`5` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
# gender
summary(survey$S1)
survey$gender <- factor(dplyr::recode(survey$S1,
`1` = "Male",
`2` = "Female"))
summary(survey$gender)
# religion
table(survey$F7)
survey$religion <- dplyr::recode(survey$F7,
`1` = "Protestant",
`2` = "Catholic",
`3` = "Jewish",
`4` = "Other (write in)",
`5` = "None",
`6` = "Not sure")
survey$religion <- factor(survey$religion)
table(survey$religion)
# subset
survey_842105voters <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_842105voters)
saveRDS(survey_842105voters, file = "survey_842105voters.rds")
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Files for Bobo/Harris 1986 Business Week National Issues Survey, study no. 861208")
require("dplyr")
survey <- read.table("harris_s861208_spss.tab", header = TRUE)
### fix everything below for this survey
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <- 861208
# study year (year)
survey$year <- 1986
# geographic data (urban)
survey$urban <- NA
# geographic data (region)
survey$region <- NA
# respondent head of household (hh)
survey$hh <- NA
# increasing inequality (inequality)
table(survey$Q2_2)
survey$inequality <- recode(as.character(survey$Q2_2),
`1` = "Feel",
`2` = "Don't Feel",
`3` = "Not Sure")
survey$inequality <- as.factor(survey$inequality)
table(survey$inequality)
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
table(survey$F4_1)
survey$union.self <- recode(survey$F4_1,
`0` = "No",
`1` = "Yes")
table(survey$union.self)
survey$union.other <- recode(survey$F4_2,
`0` = "No",
`1` = "Yes")
table(survey$union.other)
table(survey$F4_4) # not sure
survey[survey$F4_4 == 1, c("union.self", "union.other", "F4_3")]
survey$union.self[survey$F4_4 == 1] <- "Not Sure"
survey$union.other[survey$F4_4 == 1] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- factor(survey$union.other)
# employment (employed)
survey$employed <- NA
# occupation
table(survey$F1)
survey$occupation <- recode(survey$F1,
`1` = "Professional",
`2` = "Manager, official",
`3` = "Proprietor (small business)",
`4` = "Clerical worker",
`5` = "Sales worker",
`6` = "Skilled craftsman, foreman",
`7` = "Operative, unskilled laborer (except farm)",
`8` = "Service worker",
`9` = "Farmer, farm manager, farm laborer",
`10` = "Student",
`11` = "Housewife",
`12` = "Military service",
`13` = "Unemployed",
`14` = "Retired",
`15` = "Welfare",
`16` = "Disabled",
`17` = "Other (specify)",
`18` = "Not sure")
survey$occupation <- as.factor(survey$occupation)
table(survey$occupation)
survey$occupation <- factor(survey$occupation)
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
table(survey$F3)
survey$educ <- recode(survey$F3,
`1` = "Less than high school",
`2` = "High school graduate",
`3` = "Some college",
`4` = "College graduate",
`5` = "Post graduate")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate"),
labels =  c("Less than high school", "High school graduate",
"Some college", "College graduate", "Post graduate"),
ordered = TRUE)
table(survey$educ)
# household income (income)
table(survey$F10)
survey$income <- recode(survey$F10,
`1` = "Under $7500",
`2` = "$7,501 to $15,000",
`3` = "$15,001 to $25,000",
`4` = "$25,001 to $35,000",
`5` = "$35,001 to $50,000",
`6` = "$50,001 and over",
`7` = "Not sure/refused")
survey$income <- factor(survey$income,
levels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"),
labels = c("Under $7500",
"$7,501 to $15,000",
"$15,001 to $25,000",
"$25,001 to $35,000",
"$35,001 to $50,000",
"$50,001 and over",
"Not sure/refused"))
table(survey$income)
# age
table(survey$F2)
survey$age <- recode(survey$F2,
`1` = "18 to 20",
`2` = "21 to 24",
`3` = "25 to 29",
`4` = "30 to 34",
`5` = "35 to 39",
`6` = "40 to 49",
`7` = "50 to 64",
`8` = "65 to 74",
`9` = "75 and over",
`10` = "Refused")
survey$age <- factor(survey$age,
levels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Refused"),
labels = c("18 to 20",
"21 to 24",
"25 to 29",
"30 to 34",
"35 to 39",
"40 to 49",
"50 to 64",
"65 to 74",
"75 and over",
"Refused"))
table(survey$age)
# race
table(survey$F12)
survey$race <- recode(survey$F12,
`1` = "White",
`2` = "Black",
`3` = "Oriental/Asian or Pacific Islander",
`4` = "American Indian or Alaskan native",
`5` = "Not sure")
survey$race <- as.factor(survey$race)
table(survey$race)
# politics (party)
table(survey$F8)
survey$party <- recode(survey$F8,
`1` = "Republican",
`2` = "Democrat",
`3` = "Independent",
`4` = "Other",
`5` = "Not sure")
survey$party <- factor(survey$party)
table(survey$party)
# politics (ideology)
table(survey$F6)
survey$ideology <- recode(survey$F6,
`1` = "Conservative",
`2` = "Middle of the road",
`3` = "Liberal",
`4` = "Not sure")
survey$ideology <- factor(survey$ideology)
table(survey$ideology)
